package com.itqf.controller.interceper;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/21
 * @Time: 上午11:51
 */
public class LoginIntercepter implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
       //判断用户有没有登录
        Object o = request.getSession().getAttribute("user");
        if (o==null){
            //没登录
            response.sendRedirect("/login.jsp");
            return false;
        }

        return  true;
    }
}
